﻿<UserControl
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	xmlns:local="clr-namespace:EIA.SLClient.ProjectManage.Basic"
	xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
	xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" 
	xmlns:EIA_SLClient_Utility="clr-namespace:EIA.SLClient.Utility;assembly=EIA.SLClient.Utility"
	xmlns:EIA_SLClient_Utility_Behaviors="clr-namespace:EIA.SLClient.Utility.Behaviors;assembly=EIA.SLClient.Utility"
	xmlns:EIA_SLClient_Utility_Converters="clr-namespace:EIA.SLClient.Utility.Converters;assembly=EIA.SLClient.Utility"
	xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
	mc:Ignorable="d"
	x:Class="EIA.SLClient.ProjectManage.Basic.ProjectListView"
	d:DesignWidth="1024" d:DesignHeight="480">
	<UserControl.Resources>
		<local:ProjectListViewModel x:Key="ProjectListViewModelDataSource" />
		<Style x:Key="TextDataGridCellStyle" TargetType="sdk:DataGridCell">
			<Setter Property="Background" Value="Transparent"/>
			<Setter Property="HorizontalContentAlignment" Value="Left"/>
			<Setter Property="VerticalContentAlignment" Value="Center"/>
			<Setter Property="IsTabStop" Value="False"/>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="sdk:DataGridCell">
						<Grid x:Name="Root" Background="{TemplateBinding Background}">
							<Grid.ColumnDefinitions>
								<ColumnDefinition/>
								<ColumnDefinition Width="Auto"/>
							</Grid.ColumnDefinitions>
							<VisualStateManager.VisualStateGroups>
								<VisualStateGroup x:Name="CurrentStates">
									<VisualState x:Name="Regular"/>
									<VisualState x:Name="Current"/>
								</VisualStateGroup>
								<VisualStateGroup x:Name="ValidationStates">
									<VisualState x:Name="Valid"/>
									<VisualState x:Name="Invalid"/>
								</VisualStateGroup>
							</VisualStateManager.VisualStateGroups>
							<Rectangle x:Name="FocusVisual" StrokeThickness="1" Fill="#66FFFFFF" IsHitTestVisible="false" Opacity="0" />
							<ContentPresenter Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" Cursor="{TemplateBinding Cursor}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="{TemplateBinding Padding}" />
							<Rectangle x:Name="RightGridLine" Grid.Column="1" Width="1" Margin="0,0,-1,0" />
						</Grid>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
			<Setter Property="Padding" Value="4,0"/>
		</Style>
		<Style x:Key="NumberDataGridCellStyle" TargetType="sdk:DataGridCell">
			<Setter Property="Background" Value="Transparent"/>
			<Setter Property="HorizontalContentAlignment" Value="Right"/>
			<Setter Property="VerticalContentAlignment" Value="Center"/>
			<Setter Property="IsTabStop" Value="False"/>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="sdk:DataGridCell">
						<Grid x:Name="Root" Background="{TemplateBinding Background}">
							<Grid.ColumnDefinitions>
								<ColumnDefinition/>
								<ColumnDefinition Width="Auto"/>
							</Grid.ColumnDefinitions>
							<VisualStateManager.VisualStateGroups>
								<VisualStateGroup x:Name="CurrentStates">
									<VisualState x:Name="Regular"/>
									<VisualState x:Name="Current">
										<Storyboard>
											<DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="FocusVisual"/>
										</Storyboard>
									</VisualState>
								</VisualStateGroup>
								<VisualStateGroup x:Name="ValidationStates">
									<VisualState x:Name="Valid"/>
									<VisualState x:Name="Invalid">
										<Storyboard>
											<ColorAnimation Duration="0" To="#FFFFFFFF" Storyboard.TargetProperty="(Fill).Color" Storyboard.TargetName="FocusVisual"/>
										</Storyboard>
									</VisualState>
								</VisualStateGroup>
							</VisualStateManager.VisualStateGroups>
							<Rectangle x:Name="FocusVisual" Fill="#66FFFFFF" HorizontalAlignment="Stretch" IsHitTestVisible="false" Opacity="0" Stroke="#FF6DBDD1" StrokeThickness="1" VerticalAlignment="Stretch"/>
							<ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
							<Rectangle x:Name="RightGridLine" Grid.Column="1" VerticalAlignment="Stretch" Width="1"/>
						</Grid>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
			<Setter Property="Padding" Value="4,0"/>
		</Style>
		<DataTemplate x:Key="PrjNameDataTemplate">
			<Grid d:DesignWidth="232">
				<Button HorizontalAlignment="Left" d:LayoutOverrides="Height" Style="{StaticResource bs_clear}" VerticalAlignment="Center" CommandParameter="{Binding Mode=OneWay}" Foreground="#FF806C97" FontWeight="Bold" Cursor="Hand">
					<EIA_SLClient_Utility:BindingHelper.AncestorBinding>
						<EIA_SLClient_Utility:AncestorBinding TargetPath="Command" AncestorPath="DataContext.ViewItemCommand" AncestorTypeName="DataGrid"/>
					</EIA_SLClient_Utility:BindingHelper.AncestorBinding>
					<TextBlock TextWrapping="Wrap" Text="{Binding PrjName}" VerticalAlignment="Center"/>
				</Button>
			</Grid>
		</DataTemplate>
	</UserControl.Resources>

	<Grid x:Name="LayoutRoot" DataContext="{Binding Source={StaticResource ProjectListViewModelDataSource}}">
		<i:Interaction.Triggers>
			<i:EventTrigger>
				<ei:CallMethodAction TargetObject="{Binding Mode=OneWay}" MethodName="OnLoad"/>
			</i:EventTrigger>
		</i:Interaction.Triggers>
		<Grid Margin="4" Background="#FFF2F2F2">
			<Grid.Effect>
				<DropShadowEffect BlurRadius="1" ShadowDepth="1" Opacity="0.1"/>
			</Grid.Effect>
			<Grid.RowDefinitions>
				<RowDefinition Height="29"/>
				<RowDefinition/>
				<RowDefinition Height="30"/>
			</Grid.RowDefinitions>
			<Border BorderBrush="#FFE1E1E1" BorderThickness="1">
				<Border.Background>
					<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
						<GradientStop Color="#FFFCFCFC" Offset="0"/>
						<GradientStop Color="#FFEBEBEB" Offset="1"/>
					</LinearGradientBrush>
				</Border.Background>
				<Grid>
					<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,-1">
						<Button HorizontalAlignment="Left" Width="90" Style="{StaticResource bs_clear}">
							<Button.Background>
								<ImageBrush Stretch="Fill" ImageSource="/EIA.SLClient.ProjectManage.Basic;component/assets/img/导出结果-1.png"/>
							</Button.Background>
							<i:Interaction.Behaviors>
								<EIA_SLClient_Utility_Behaviors:Background4StateBehavior>
									<EIA_SLClient_Utility_Behaviors:Background4StateBehavior.BackgroundPressed>
										<ImageBrush Stretch="Fill" ImageSource="/EIA.SLClient.ProjectManage.Basic;component/assets/img/导出结果-2.png"/>
									</EIA_SLClient_Utility_Behaviors:Background4StateBehavior.BackgroundPressed>
									<EIA_SLClient_Utility_Behaviors:Background4StateBehavior.BackgroundNormal>
										<ImageBrush Stretch="Fill" ImageSource="/EIA.SLClient.ProjectManage.Basic;component/assets/img/导出结果-1.png"/>
									</EIA_SLClient_Utility_Behaviors:Background4StateBehavior.BackgroundNormal>
									<EIA_SLClient_Utility_Behaviors:Background4StateBehavior.BackgroundMouseOver>
										<ImageBrush Stretch="Fill" ImageSource="/EIA.SLClient.ProjectManage.Basic;component/assets/img/导出结果-2.png"/>
									</EIA_SLClient_Utility_Behaviors:Background4StateBehavior.BackgroundMouseOver>
									<EIA_SLClient_Utility_Behaviors:Background4StateBehavior.BackgroundDisabled>
										<ImageBrush Stretch="Fill" ImageSource="/EIA.SLClient.ProjectManage.Basic;component/assets/img/导出结果-1.png" Opacity="0.4"/>
									</EIA_SLClient_Utility_Behaviors:Background4StateBehavior.BackgroundDisabled>
								</EIA_SLClient_Utility_Behaviors:Background4StateBehavior>
							</i:Interaction.Behaviors>
						</Button>
					</StackPanel>
					<StackPanel HorizontalAlignment="Left" Margin="8,0,0,0" Orientation="Horizontal" MinWidth="100">
						<TextBlock TextWrapping="Wrap" Text="{Binding QueryTitle}" HorizontalAlignment="Left" VerticalAlignment="Center" Foreground="#FF75AC47"/>
						<HyperlinkButton Content="重新载入" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="8,0,0,0" Command="{Binding RetrieveItemsCommand}" Visibility="{Binding QueryTitle, Converter={StaticResource NotNull2VisibilityConverter}}"/>
					</StackPanel>
				</Grid>
			</Border>
			<Border BorderBrush="#FFE1E1E1" BorderThickness="1,0" Grid.Row="1">
				<Grid>
					<sdk:DataGrid FrozenColumnCount="1" ItemsSource="{Binding ProjectCollection}">
						<sdk:DataGrid.Columns>
							<sdk:DataGridTemplateColumn Header="项目名称" MinWidth="240" CanUserSort="True"  CellStyle="{StaticResource TextDataGridCellStyle}" SortMemberPath="PrjName" CellTemplate="{StaticResource PrjNameDataTemplate}" />
							<sdk:DataGridTextColumn Header="项目类型" Binding="{Binding PrjType, ConverterParameter=XMLX, Converter={StaticResource DicItemConverter}}" CanUserSort="True" />
							<sdk:DataGridTextColumn Header="项目负责人" Binding="{Binding PrjLeaderName}" CanUserSort="True"  CellStyle="{StaticResource TextDataGridCellStyle}"/>
							<sdk:DataGridTextColumn Header="主持工程师" Binding="{Binding PrjEngineerName}" CanUserSort="True"  CellStyle="{StaticResource TextDataGridCellStyle}"/>
							
							<sdk:DataGridTextColumn Header="建设单位" Binding="{Binding PrjConsOrg}" CanUserSort="True"  CellStyle="{StaticResource TextDataGridCellStyle}"/>
							<sdk:DataGridTextColumn Header="项目进度" Binding="{Binding Progress, ConverterParameter=XMJD, Converter={StaticResource DicItemConverter}}" CanUserSort="True" />
                            <sdk:DataGridTextColumn Header="项目承接日期" Binding="{Binding Date, StringFormat=yyyy-MM-dd}" CanUserSort="True" />
							<sdk:DataGridTextColumn Header="计划完成日期" Binding="{Binding PrjScheduled, StringFormat=yyyy-MM-dd}" CanUserSort="True" />
							<sdk:DataGridTextColumn Header="归档情况" Binding="{Binding Filed, ConverterParameter=GDZT, Converter={StaticResource DicItemConverter}}" CanUserSort="True" />
						</sdk:DataGrid.Columns>
					</sdk:DataGrid>
				</Grid>
			</Border>
			<Border BorderBrush="#FFE1E1E1" BorderThickness="1" Grid.Row="2" Background="WhiteSmoke">
				<Grid>
					<EIA_SLClient_Utility:DataPagerControl HorizontalAlignment="Right" Margin="0,0,8,0" VerticalAlignment="Center" PageSize="{Binding PageSize, Mode=TwoWay}" TotalCount="{Binding TotalCount}" PageIndex="{Binding PageIndex, Mode=TwoWay}"/>
				</Grid>
			</Border>
		</Grid>
	</Grid>
</UserControl>
